package com.shuiyun.chat.service;

import cn.hutool.core.util.IdUtil;
import io.netty.channel.Channel;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @program: chatServer
 * @description: 客户端服务类
 * @author: shuiyun
 * @create: 2021-05-12 23:46
 **/
@Service
public class ClientService {

    private Map<String, Channel> channelMap = null;


    public ClientService(){
        channelMap = new HashMap<>();
    }

    /**
     *客户上线处理
     * @param channel 客户的通道
     * @Author: shuiyun
     * @Date: 2021/5/13 0:15
     * @return 通道ID
     */
    public void online(String userName,Channel channel){
        channelMap.put(userName,channel);
    }

    /**
     * 根据用户名获取自己的通道
     * @param
     * @author shuiyun
     * @date 2021/5/14 15:36
     * @return
     */
    public Channel getChannel(String userName){
        return channelMap.get(userName);
    }
}
